(() => {
  // 字符串类型
  let a: string = '123'
  let str: string = `dddd${a}`
  console.log(str);  //dddd123

  // 数字类型
  let notANumber: number = NaN
  let num: number = 123
  let infinity: number = Infinity
  let decimal: number = 6
  let hex: number = 0xf00d
  let binary: number = 0b1010
  let octal: number = 0o777
  console.log(notANumber, num, infinity, decimal, hex, binary, octal); //NaN 123 Infinity 6 61453 10 511

  // 布尔类型
  let booleand: boolean = true         //可传布尔值
  let booleand2: boolean = Boolean(1)  //可传函数Boolean()返回布尔值
  let createrBoolean: Boolean = new Boolean(1)  //可创建Boolean对象,注意大写
  console.log(booleand, booleand2, createrBoolean); //true true [Boolean: true]

  // 数组类型
  // 1. 多维数组
  let list: number[] = [1, 2, 3, 4, 5]
  let list2: Array<Array<number>> = [[1, 2], [3, 4], [5, 6]]
  let list3: Array<number[]> = [[1, 2], [3, 4], [5, 6]]
  console.log(list, list2, list3);
  // 2. 类数组arguments
  function Arr(...args: any): void {
    // let arr:number[] = arguments //类型“IArguments”缺少类型“number[]”的以下属性: pop, push, concat, join 及其他 27 项
    let arr: IArguments = arguments //IArguments是TypeScript中定义好的类型
    console.log(arr);
  }
  Arr(1, 2, 3, 4, 5); //[Arguments] { '0': 1, '1': 2, '2': 3, '3': 4, '4': 5 }
  /**
   * 内置接口IArguments
   * interface IArguments {
   *     [index: number]: any;
   *     length: number;
   *     callee: Function }
   */
  // 3. 接口表示数组
  interface NumberArray {
    [index: number]: number
  }
  let arr4: NumberArray = [1, 2, 3, 4, 5]
  console.log(arr4); //[1, 2, 3, 4, 5]

  let list4: any[] = [1, '2', true, null, undefined, { name: 'zhangsan' }]
  console.log(list4); //[1, "2", true, null, undefined, { name: 'zhangsan' }]

  // IArguments 中的callee属性是函数，所以不能用作数组类型
  // let list5:IArguments = [1, '2', true, null, undefined, {name: 'zhangsan'}] ×

  // 4. 元组类型
  let x: [string, number]
  x = ['hello', 10]
  console.log(x[0], x[1]);
  // x = [10, 'hello'] ×  元组赋值要一一对应
  let arr2: readonly [string, number] = ['hello', 10]
  // arr2[0] = 'world' × 元组类型是只读的，不能修改
  let y: [string, number, boolean]
  y = ['hello', 10, true]
  console.log(y.length);
  // console.log(y[1].length); × 字符串有长度，数字、布尔值、undefined、null没有长度
  // 越界元素
  // y[3] = false × 元组类型长度固定，越界元素会报错
  // y.push(undefined); //添加元素, 一定要添加本身数组含有的类型，否则会报错
  console.log(y); //["hello", 10, true, "world"]

  // 元组类型-应用场景
  let excel: [string, string, number, string][] = [
    ['张三', '男', 20, '13812345678'],
    ['王五', '男', 21, '13812345670'],
    ['李四', '女', 19, '13812345679'],
    ['李四', '女', 10, '13812345639']
  ]

  //  5. 空值类型void
  function voidFn(): void {
    console.log("voidFn~~");
  }
  voidFn()
  // void也可以定义undefined和null类型
  let u: void = undefined
  // let n: void = null  //严格模式下报错
  console.log(u); //undefined 
})()






